#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <math.h> 
#include <ctype.h> 
#include <time.h> 
#include <assert.h>

typedef long long LL;
LL f[1000000] = { 0 };
int n, m;

int main()
{
	scanf("%d%d", &n, &m);

	int x;
	scanf("%d", &x);
	for (int i = 2; i <= m; i++)
	{
		int y = 0;
		scanf("%d", &y);
		if (x < y)
		{
			f[x]++;
			f[y]--;
		}
		else
		{
			f[y]++;
			f[x]--;
		}
		x = y;
	}

	for (int i = 1; i <= n; i++)
		f[i] += f[i - 1];

	LL ret = 0;
	for (int i = 1; i <= n; i++)
	{
		LL a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		LL sum1 = a * f[i];
		LL sum2 = c + b * f[i];
		ret += sum1 < sum2 ? sum1 : sum2;
	}

	printf("%lld\n", ret);

	return 0;
}
